<?php
require("config.php");
require("common_start.php");
require("lib/func.lib.php");
$pageLoad = $_REQUEST['loadData'];
if($pageLoad == 'Home') {
    echo json_encode(getDataToHomePage($conn));
}
function getDataToHomePage($conn){
    $pageIndex = $_REQUEST['pageIndex'];
    $pageSize = $_REQUEST['pageSize'];
    $sql = "select tbl_product.id,tbl_product.price,tbl_product.name,tbl_product.image from tbl_product order by tbl_product.last_modified DESC limit " .
        $pageSize * $pageIndex. "," .$pageSize;
    $resultDB = @mysql_query($sql, $conn);
    $total = countRecord("tbl_product", "status=0");
    $arrData = array();
    while($products = mysql_fetch_assoc($resultDB)){
        $id = $products['id'];
        $strLinkFriendly = unicodeToNonUnicode($products['name']);
        $products['priceFormat'] = number_format($products['price'], 0);
        $products['linkFriendly'] = $strLinkFriendly;
        $arrData[$id] = $products;
    }
    return $arrData;
}
?>